package com.spring.cn.config.factory;

import java.util.HashMap;
import java.util.Map;

/**
 * @author liangd
 * date 2020-11-14 14:25
 * code 静态工厂方法：直接调用一个类的静态方法就可以返回Bean的实例
 */
public class StaticCarBeanFactory {

    private static Map<String,CarBean> map = new HashMap<String, CarBean>();

    static {
        map.put("baoma",new CarBean("宝马",500000));
        map.put("audi",new CarBean("奥迪",300000));
    }

    //静态工厂方法
    public static CarBean getCar(String name){
        return  map.get(name);
    }
}
